import 'dart:convert';

import 'package:flutter_deer/database/beans/get_user_info_entity.dart';
import 'package:flutter_deer/database/beans/pay/create_order_entity.dart';
import 'package:flutter_deer/generated/json/base/json_field.dart';
import 'package:flutter_deer/generated/json/post_discount_entity.g.dart';
export 'package:flutter_deer/generated/json/post_discount_entity.g.dart';

@JsonSerializable()
class PostDiscountEntity {
	bool? compositePay = false;
	List<Coupon>? couponList = [];
	int? couponSelectType = 0;
	String? energyCategoryId = '';
	String? energyGoodsId = '';
	bool? fullPay = false;
	int? lastPayAmount = 0;
	String? loginMchCode = GetUserInfoEntity.get()?.loginMerchantCode?? '';
	int? loginMchType = GetUserInfoEntity.get()?.loginMerchantType;
	String? mchMemberId = '';
	String? memberAccountId = '';
	String? orderAmount = '';
	int? paidAmount = 0;
	int? payAmount = 0;
	String? payType = '';
	String? price = '';
	String? quantity = '';
	List<StoreGoodsInfos>? storeGoodsInfos = [];
	bool? useCoupon = true;
	String? useIntegral = '';

	PostDiscountEntity();

	factory PostDiscountEntity.fromJson(Map<String, dynamic> json) => $PostDiscountEntityFromJson(json);

	Map<String, dynamic> toJson() => $PostDiscountEntityToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}

	String toBaseString() {
		return '油金额：${orderAmount} 升数：${quantity} 单价：${price} 支付方式：${payType}';
	}
}

@JsonSerializable()
class Coupon {
	int? couponNum = 0;
	String? mchCouponId = '';
	String? memberCouponId = '';

	Coupon();

	factory Coupon.fromJson(Map<String, dynamic> json) => $CouponFromJson(json);

	Map<String, dynamic> toJson() => $CouponToJson(this);

	@override
	String toString() {
		return jsonEncode(this);
	}
}
